sealed class Result<T> {
  const Result();

  const factory Result.ok(T value) = Ok<T>._;

  const factory Result.error(Exception error) = Error<T>._;
}

final class Ok<T> extends Result<T> {
  const Ok._(this.value);

  final T value;

  // 忽略下面的辅助方法（不参与覆盖率统计）
  // LCOV_EXCL_START
  @override
  String toString() => 'Result<$T>.ok{$value}';
  // LCOV_EXCL_END
}

final class Error<T> extends Result<T> {
  const Error._(this.error);

  final Exception error;

  // LCOV_EXCL_LINE
  @override
  String toString() => 'Result<$T>.error{$error}';
}
